package net.qhzw.admin.controller;

import net.qhzw.admin.param.PersonnelParam;
import net.qhzw.admin.query.PersonnelQuery;
import net.qhzw.admin.service.PersonnelService;
import net.qhzw.common.model.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/***
 * 人员管理前端控制器
 */

@RestController
@RequestMapping("sys/personnel")
public class PersonnelController {

    @Autowired
    private PersonnelService personnelService;


    /****
     * 新增人员
     * @return
     */
    @PostMapping
    public JsonResult addToPersonnel(PersonnelParam param, MultipartFile file) {
        return personnelService.addToPersonnel(param, file);
    }

    /***
     * 获取人员列表
     * @param query
     * @return
     */
    @GetMapping
    public JsonResult getPersonnelList(PersonnelQuery query) {
        return personnelService.getPersonnelList(query);
    }


    /***
     * 删除人员
     * @return
     */
    @DeleteMapping("/{id}")
    public JsonResult deletePersonnel(@PathVariable(value = "id") String id) {
        return personnelService.deletePersonnel(id);
    }


    /***
     * 获取当前人员
     * @return
     */
    @GetMapping("/{id}")
    public JsonResult getPersonnel(@PathVariable(value = "id") String id) {
        return personnelService.getPersonnel(id);
    }


    /***
     * 修改人员信息
     * @param param
     * @param file
     * @return
     */
    @PutMapping
    public JsonResult update(PersonnelParam param, MultipartFile file) {
        return personnelService.addToPersonnel(param, file);
    }


}
